{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7b8d634b-a637-469d-b2c7-c11154b657cb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 在jupyterlab中使用pyecharts的环境设置\n",
    "from pyecharts.globals import CurrentConfig, NotebookType\n",
    "CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7a85de3a-cc77-4947-9376-763f6b7f20f0",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入包\n",
    "# Boxplot是箱线图\n",
    "from pyecharts.charts import Boxplot\n",
    "from pyecharts import options as opt\n",
    "\n",
    "# Faker是pyecharts提供的一个测试数据生成模块\n",
    "from pyecharts.faker import Faker"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "31901202-95c2-4d02-b239-218484553e94",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 创建测试数据\n",
    "\n",
    "v1 = [\n",
    "    [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880]\n",
    "    + [1000, 980, 900, 650, 930, 850, 810, 1000, 980, 1000],\n",
    "    [960, 940, 960, 970, 930, 850, 880, 980, 980, 880]\n",
    "    + [840, 830, 900, 810, 790, 850, 800, 760, 770, 880]\n",
    "]\n",
    "v2 = [\n",
    "    [890, 810, 820, 810, 730, 750, 750, 780, 780, 780]\n",
    "    + [890, 980, 900, 650, 930, 850, 810, 1000, 980, 900],\n",
    "    [860, 840, 860, 870, 730, 750, 880, 880, 780, 780]\n",
    "    + [840, 830, 800, 810, 790, 820, 800, 760, 710, 820]\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "2e3f14b1-3783-432d-ab5f-670ba2e7afb0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"715cdf6819164bc6955dacca501ddda3\" class=\"chart-container\" style=\"width:900px; height:500px; \"></div>\n",
       "    <script>\n",
       "        var chart_715cdf6819164bc6955dacca501ddda3 = echarts.init(\n",
       "            document.getElementById('715cdf6819164bc6955dacca501ddda3'), 'white', {renderer: 'canvas'});\n",
       "        var option_715cdf6819164bc6955dacca501ddda3 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"boxplot\",\n",
       "            \"name\": \"\\u7b2c\\u4e00\\u5b63\\u5ea6\",\n",
       "            \"boxWidth\": [\n",
       "                7,\n",
       "                50\n",
       "            ],\n",
       "            \"selected_mode\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    650,\n",
       "                    850.0,\n",
       "                    930.0,\n",
       "                    980.0,\n",
       "                    1070\n",
       "                ],\n",
       "                [\n",
       "                    760,\n",
       "                    815.0,\n",
       "                    880.0,\n",
       "                    955.0,\n",
       "                    980\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                }\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"margin\": 8\n",
       "                }\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"boxplot\",\n",
       "            \"name\": \"\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\n",
       "            \"boxWidth\": [\n",
       "                7,\n",
       "                50\n",
       "            ],\n",
       "            \"selected_mode\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    650,\n",
       "                    780.0,\n",
       "                    815.0,\n",
       "                    900.0,\n",
       "                    1000\n",
       "                ],\n",
       "                [\n",
       "                    710,\n",
       "                    780.0,\n",
       "                    815.0,\n",
       "                    855.0,\n",
       "                    880\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                }\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"margin\": 8\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u7b2c\\u4e00\\u5b63\\u5ea6\",\n",
       "                \"\\u7b2c\\u4e8c\\u5b63\\u5ea6\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u7269\\u54c1A\",\n",
       "                \"\\u7269\\u54c1B\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_715cdf6819164bc6955dacca501ddda3.setOption(option_715cdf6819164bc6955dacca501ddda3);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x107407490>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "boxplot = Boxplot()\n",
    "boxplot.add_xaxis([\"物品A\", \"物品B\"])\n",
    "boxplot.add_yaxis(\"第一季度\", boxplot.prepare_data(v1))\n",
    "boxplot.add_yaxis(\"第二季度\", boxplot.prepare_data(v2))\n",
    "boxplot.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f7e3cb95-7a1b-4e02-afb2-8a7829585c61",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f1d2eccf-bc44-4957-be04-f7ffa870d99d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>Name</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Age</th>\n",
       "      <th>Height</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Team</th>\n",
       "      <th>NOC</th>\n",
       "      <th>Games</th>\n",
       "      <th>Year</th>\n",
       "      <th>Season</th>\n",
       "      <th>City</th>\n",
       "      <th>Sport</th>\n",
       "      <th>Event</th>\n",
       "      <th>Medal</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>A Dijiang</td>\n",
       "      <td>M</td>\n",
       "      <td>24.0</td>\n",
       "      <td>180.0</td>\n",
       "      <td>80.0</td>\n",
       "      <td>China</td>\n",
       "      <td>CHN</td>\n",
       "      <td>1992 Summer</td>\n",
       "      <td>1992</td>\n",
       "      <td>Summer</td>\n",
       "      <td>Barcelona</td>\n",
       "      <td>Basketball</td>\n",
       "      <td>Basketball Men's Basketball</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>A Lamusi</td>\n",
       "      <td>M</td>\n",
       "      <td>23.0</td>\n",
       "      <td>170.0</td>\n",
       "      <td>60.0</td>\n",
       "      <td>China</td>\n",
       "      <td>CHN</td>\n",
       "      <td>2012 Summer</td>\n",
       "      <td>2012</td>\n",
       "      <td>Summer</td>\n",
       "      <td>London</td>\n",
       "      <td>Judo</td>\n",
       "      <td>Judo Men's Extra-Lightweight</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Gunnar Nielsen Aaby</td>\n",
       "      <td>M</td>\n",
       "      <td>24.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Denmark</td>\n",
       "      <td>DEN</td>\n",
       "      <td>1920 Summer</td>\n",
       "      <td>1920</td>\n",
       "      <td>Summer</td>\n",
       "      <td>Antwerpen</td>\n",
       "      <td>Football</td>\n",
       "      <td>Football Men's Football</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Edgar Lindenau Aabye</td>\n",
       "      <td>M</td>\n",
       "      <td>34.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Denmark/Sweden</td>\n",
       "      <td>DEN</td>\n",
       "      <td>1900 Summer</td>\n",
       "      <td>1900</td>\n",
       "      <td>Summer</td>\n",
       "      <td>Paris</td>\n",
       "      <td>Tug-Of-War</td>\n",
       "      <td>Tug-Of-War Men's Tug-Of-War</td>\n",
       "      <td>Gold</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Christine Jacoba Aaftink</td>\n",
       "      <td>F</td>\n",
       "      <td>21.0</td>\n",
       "      <td>185.0</td>\n",
       "      <td>82.0</td>\n",
       "      <td>Netherlands</td>\n",
       "      <td>NED</td>\n",
       "      <td>1988 Winter</td>\n",
       "      <td>1988</td>\n",
       "      <td>Winter</td>\n",
       "      <td>Calgary</td>\n",
       "      <td>Speed Skating</td>\n",
       "      <td>Speed Skating Women's 500 metres</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ID                      Name Sex   Age  Height  Weight            Team  \\\n",
       "0   1                 A Dijiang   M  24.0   180.0    80.0           China   \n",
       "1   2                  A Lamusi   M  23.0   170.0    60.0           China   \n",
       "2   3       Gunnar Nielsen Aaby   M  24.0     NaN     NaN         Denmark   \n",
       "3   4      Edgar Lindenau Aabye   M  34.0     NaN     NaN  Denmark/Sweden   \n",
       "4   5  Christine Jacoba Aaftink   F  21.0   185.0    82.0     Netherlands   \n",
       "\n",
       "   NOC        Games  Year  Season       City          Sport  \\\n",
       "0  CHN  1992 Summer  1992  Summer  Barcelona     Basketball   \n",
       "1  CHN  2012 Summer  2012  Summer     London           Judo   \n",
       "2  DEN  1920 Summer  1920  Summer  Antwerpen       Football   \n",
       "3  DEN  1900 Summer  1900  Summer      Paris     Tug-Of-War   \n",
       "4  NED  1988 Winter  1988  Winter    Calgary  Speed Skating   \n",
       "\n",
       "                              Event Medal  \n",
       "0       Basketball Men's Basketball   NaN  \n",
       "1      Judo Men's Extra-Lightweight   NaN  \n",
       "2           Football Men's Football   NaN  \n",
       "3       Tug-Of-War Men's Tug-Of-War  Gold  \n",
       "4  Speed Skating Women's 500 metres   NaN  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读取数据\n",
    "data = pd.read_csv(\"athlete_events.csv\")\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "c65fb49b-8590-45b5-8d6b-711aaaffc7a6",
   "metadata": {},
   "outputs": [],
   "source": [
    "selectedCountries = {\n",
    "    \"CHN\": \"中国\",\n",
    "    \"JPN\": \"日本\",\n",
    "    \"KOR\": \"韩国\",\n",
    "    \"USA\": \"美国\",\n",
    "    \"GBR\": \"英国\",\n",
    "    \"FRA\": \"法国\",\n",
    "    \"ITA\": \"意大利\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "cb101cc2-f220-4887-a04d-a51be86743fe",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取指定国家的所有运动员数据\n",
    "selectedAthletes = data[data[\"NOC\"].isin(selectedCountries.keys())]\n",
    "\n",
    "# 创建存放男运动员信息的列表\n",
    "maleAthletesHeights = []\n",
    "\n",
    "# 创建存放女运动员信息的列表\n",
    "femaleAthletesHeights = []\n",
    "\n",
    "# 提取数据\n",
    "for country in selectedCountries.keys():\n",
    "    maleHeight = selectedAthletes[(selectedAthletes[\"NOC\"]==country) & (selectedAthletes[\"Sex\"]==\"M\")][\"Height\"].dropna().tolist()\n",
    "    femaleHeight = selectedAthletes[(selectedAthletes[\"NOC\"]==country) & (selectedAthletes[\"Sex\"]==\"F\")][\"Height\"].dropna().tolist()\n",
    "    maleAthletesHeights.append(maleHeight)\n",
    "    femaleAthletesHeights.append(femaleHeight)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f0983c68-ca8a-4772-9836-aa6aec7e771f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<html>\n",
       "<head>\n",
       "    <meta charset=\"UTF-8\">\n",
       "</head>\n",
       "<body>\n",
       "        <div id=\"0a352567f2564acd92b141cc33fc4ac4\" class=\"chart-container\" style=\"width:800px; height:400px; \"></div>\n",
       "    <script>\n",
       "        var chart_0a352567f2564acd92b141cc33fc4ac4 = echarts.init(\n",
       "            document.getElementById('0a352567f2564acd92b141cc33fc4ac4'), 'white', {renderer: 'canvas'});\n",
       "        var option_0a352567f2564acd92b141cc33fc4ac4 = {\n",
       "    \"animation\": false,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"boxplot\",\n",
       "            \"name\": \"\\u7537\\u8fd0\\u52a8\\u5458\",\n",
       "            \"boxWidth\": [\n",
       "                7,\n",
       "                50\n",
       "            ],\n",
       "            \"selected_mode\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    148.0,\n",
       "                    170.0,\n",
       "                    178.0,\n",
       "                    185.0,\n",
       "                    226.0\n",
       "                ],\n",
       "                [\n",
       "                    147.0,\n",
       "                    166.0,\n",
       "                    172.0,\n",
       "                    178.0,\n",
       "                    208.0\n",
       "                ],\n",
       "                [\n",
       "                    152.0,\n",
       "                    169.0,\n",
       "                    175.0,\n",
       "                    180.0,\n",
       "                    207.0\n",
       "                ],\n",
       "                [\n",
       "                    140.0,\n",
       "                    175.0,\n",
       "                    181.0,\n",
       "                    188.0,\n",
       "                    223.0\n",
       "                ],\n",
       "                [\n",
       "                    143.0,\n",
       "                    174.0,\n",
       "                    180.0,\n",
       "                    185.0,\n",
       "                    211.0\n",
       "                ],\n",
       "                [\n",
       "                    150.0,\n",
       "                    172.0,\n",
       "                    178.0,\n",
       "                    185.0,\n",
       "                    218.0\n",
       "                ],\n",
       "                [\n",
       "                    145.0,\n",
       "                    172.0,\n",
       "                    178.0,\n",
       "                    184.0,\n",
       "                    215.0\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                }\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"margin\": 8\n",
       "                }\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"boxplot\",\n",
       "            \"name\": \"\\u5973\\u8fd0\\u52a8\\u5458\",\n",
       "            \"boxWidth\": [\n",
       "                7,\n",
       "                50\n",
       "            ],\n",
       "            \"selected_mode\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    136.0,\n",
       "                    163.0,\n",
       "                    169.0,\n",
       "                    175.0,\n",
       "                    206.0\n",
       "                ],\n",
       "                [\n",
       "                    140.0,\n",
       "                    157.0,\n",
       "                    161.0,\n",
       "                    166.0,\n",
       "                    191.0\n",
       "                ],\n",
       "                [\n",
       "                    139.0,\n",
       "                    162.0,\n",
       "                    166.0,\n",
       "                    171.0,\n",
       "                    202.0\n",
       "                ],\n",
       "                [\n",
       "                    139.0,\n",
       "                    162.0,\n",
       "                    168.0,\n",
       "                    175.0,\n",
       "                    203.0\n",
       "                ],\n",
       "                [\n",
       "                    137.0,\n",
       "                    163.0,\n",
       "                    169.0,\n",
       "                    173.0,\n",
       "                    195.0\n",
       "                ],\n",
       "                [\n",
       "                    140.0,\n",
       "                    162.0,\n",
       "                    167.0,\n",
       "                    172.0,\n",
       "                    197.0\n",
       "                ],\n",
       "                [\n",
       "                    141.0,\n",
       "                    162.0,\n",
       "                    167.0,\n",
       "                    172.0,\n",
       "                    201.0\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                }\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"margin\": 8\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u7537\\u8fd0\\u52a8\\u5458\",\n",
       "                \"\\u5973\\u8fd0\\u52a8\\u5458\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u4e2d\\u56fd\",\n",
       "                \"\\u65e5\\u672c\",\n",
       "                \"\\u97e9\\u56fd\",\n",
       "                \"\\u7f8e\\u56fd\",\n",
       "                \"\\u82f1\\u56fd\",\n",
       "                \"\\u6cd5\\u56fd\",\n",
       "                \"\\u610f\\u5927\\u5229\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"interval\": 20,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"min\": 120,\n",
       "            \"max\": 240,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "        chart_0a352567f2564acd92b141cc33fc4ac4.setOption(option_0a352567f2564acd92b141cc33fc4ac4);\n",
       "    </script>\n",
       "</body>\n",
       "</html>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1077fb410>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 初始化箱线图对象\n",
    "bx = Boxplot(init_opts=opt.InitOpts(\n",
    "    width=\"800px\",\n",
    "    height=\"400px\",\n",
    "    animation_opts=opt.AnimationOpts(animation=False)\n",
    "))\n",
    "\n",
    "# 设置x轴坐标值\n",
    "bx.add_xaxis(xaxis_data=list(selectedCountries.values()))\n",
    "\n",
    "# 设置y轴坐标值\n",
    "bx.add_yaxis(series_name=\"男运动员\", y_axis=bx.prepare_data(maleAthletesHeights))\n",
    "bx.add_yaxis(series_name=\"女运动员\", y_axis=bx.prepare_data(femaleAthletesHeights))\n",
    "\n",
    "# 设置y轴显示范围\n",
    "bx.set_global_opts(yaxis_opts=opt.AxisOpts(interval=20, min_=120, max_=240))\n",
    "\n",
    "# 绘图\n",
    "bx.render_notebook()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
